<?php

class Form_BugReportForm extends Zend_Form
{
	public function init()
	{
		$id= $this->createElement('hidden','id');
		$this->addElement($id);
		
		$username = $this->createElement('text','username');
		$username->setLabel('Your name:');
		$username->setRequired(TRUE);
		$username->setAttrib('size',40);
		$username->addValidator('NotEmpty');
		$this->addElement($username);
		
		$password = new Zend_Form_Element_Password('password');
        $password->setLabel('Password:');
        $password->setRequired(true);
        $password->setAttrib('size', 40);
        $password->addValidator(new Zend_Validate_StringLength(6,20));
  		$password->addValidator(new Zend_Validate_Alnum());
        $password->addFilter(new Zend_Filter_HtmlEntities());
        $password->addFilter(new Zend_Filter_StripTags());
        $this->addElement($password);
		
		$email = $this->createElement('text','email');
		$email->setLabel('Email:');
		$email->setRequired(TRUE);
		$email->addValidator( new Zend_Validate_EmailAddress());
		$email->addFilters(array(new  Zend_Filter_StringTrim(),
		new Zend_Filter_StringToLower()));
		$email->setAttrib('size',40);
		$this->addElement($email);
		
		$this->addElement('submit','submit',array('label'=>'Submit'));
	}
	
    /**
     * Create email text field
     *
     * @return Zend_Form_Element_Text
     */
	
    public function getEmailTextField()
    {
        //Create Text Field Object.
        $emailElement = new Zend_Form_Element_Text('email');
        $emailElement->setLabel('Email:');
        $emailElement->setRequired(true);
 
        //Add Validator
        $emailElement->addValidator(new Zend_Validate_EmailAddress());
        //Add Filter
        $emailElement->addFilter(new Zend_Filter_HtmlEntities());
        $emailElement->addFilter(new Zend_Filter_StripTags());
        return $emailElement;
         
    }
    /**
     * Create password text field
     *
     * @return Zend_Form_Element_Password
     */
	
    public function getPasswordTextField()
    {
        //Create Password Object.
        $passwordElement = new Zend_Form_Element_Password('password');
        $passwordElement->setLabel('Password:');
        $passwordElement->setRequired(true);
        //Add Validator
        $passwordElement->addValidator
                          (
                           new Zend_Validate_StringLength(6,20)
                          );
  		$passwordElement->addValidator(new Zend_Validate_Alnum());
        //Add Filter
        $passwordElement->addFilter(new Zend_Filter_HtmlEntities());
        $passwordElement->addFilter(new Zend_Filter_StripTags());
        return $passwordElement;
    }
    /**
     * Create username text field.
     *
     * @return Zend_Form_Element_Text
     */
    
    public function getUsernameTextField()
    {
        $usernameElement = new Zend_Form_Element_Text('username');
        $usernameElement->setLabel('Username:');
        $usernameElement->setRequired(true);
        //Add validator
        $usernameElement->addValidator
                          (
                            new Zend_Validate_StringLength(6, 20)
                          );
        $usernameElement->addValidator(new Zend_Validate_Alnum());
        //Add Filter
        $usernameElement->addFilter(new Zend_Filter_StripTags());
        $usernameElement->addFilter(new Zend_Filter_HtmlEntities());
        $usernameElement->addFilter(new Zend_Filter_StringToLower());
        return $usernameElement;
    }
    
    public function getSubmitElement(){
    	 	$submitElement = new Zend_Form_Element_Submit('Submit');
    		$submitElement->setLabel('Submit');
    		return $submitElement;
    }
    
}